<?php

namespace App\Transformers\Traits;


use App\Transformers\UserTransformer;
use Illuminate\Database\Eloquent\Model;

trait WithTransformerAuthor
{
    public function includeAuthor(Model $model)
    {
        $author = $model->author;
        if (!$author) {
            return $this->null();
        }
        return $this->item($author, new UserTransformer());
    }
}